Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker #340

Merged
merged 4 commits into from
Mar 27, 2019
Merged

Docker #340

merged 4 commits into from
Mar 27, 2019

Conversation

sbrunk
Copy link
Member

@sbrunk sbrunk commented Mar 25, 2019

This is an alternative approach to almond-sh/docker-images#1.

The main differences are:

  • We have a single generic Dockerfile in the main repo.
  • When a tag is pushed, we use travis to build docker images with kernels for 2.11, 2.12 and both, and push them to docker hub.

The Dockerfile makes it easy to create a docker image from a locally built kernel by setting LOCAL_IVY=yes. This is used in travis where the images are created from locally published jars, which is why we can run this job in parallel to uploading to sonatype.

Right now it does a sbt + publishLocal in the update-docker-images script, then copies $HOME/.ivy/local into $TRAVIS_BUILD_DIR/ivy-local so we can copy it into the docker image. I think this could be improved by doing an additional publish to $TRAVIS_BUILD_DIR/ivy-local during the release stage directly. I tried but my understanding of sbt seems to be too limited.

Copy link
Member

@alexarchambault alexarchambault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few comments. That looks neat!

.travis.yml Outdated
stages:
- name: test
- name: release
if: (branch = master AND type = push) OR (tag IS present)
- name: upload-launcher
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the upload-launcher stage? Couldn't it be kept along the new upload-artifacts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because, if my understanding of travis is correct, jobs run only in parallel if they're in the same stage.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've put the upload-launcher stage back in as it was before.

Dockerfile Outdated
# i.e SCALA_VERSIONS="2.11.12 2.12.8"
ARG SCALA_VERSIONS
USER $NB_UID
RUN [ -z "$SCALA_VERSIONS" ] && echo "SCALA_VERSIONS is empty" && exit 1; \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT Maybe we could put that command in a script, to make it easier to tweak it in the future.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. That would also make it easier to reuse it outside of a docker build. I'll try to move it out.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

git add Dockerfile
git commit -m "almond $VERSION, scala $sv"
done
sbt '+ publishLocal'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to do that for releases? They should already be on Maven Central when this stage runs.

Maybe we could run that stage for snapshots (and push them with a snapshot tag say), and rely on publishLocal only for them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now it runs in parallel to the upload-launcher (see my comment about the stage) so the artifacts aren't available yet. I can change it back to run afterwards and use the published artifacts. Then only do a publishLocal for snapshots builds as you've suggested.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can run them sequentially, yes. Doing so allows to avoid the +publishLocal, so maybe it's not even slower…

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script in combination with .travis.yml differentiates now between releases and a push to master. +publishLocal runs only on master now and creates a snapshot docker image from the current HEAD. On a tag, it should grab the published artifacts instead.

scripts/update-docker-images.sh Show resolved Hide resolved
- build snapshots only when pushing to master, not when pushing a tag
- move docker job back into its own stage
.travis.yml Outdated
@@ -18,7 +18,7 @@ stages:
- name: release
if: (branch = master AND type = push) OR (tag IS present)
- name: upload-launcher
if: (branch = master AND type = push) OR tag IS present
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I this change was supposed to be applied to the update-docker-images stage in order to support snapshot images.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, np!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, my bad, I opened #343 to re-instate it.

@alexarchambault
Copy link
Member

alexarchambault commented Mar 27, 2019

About pushing the images for snapshots (I suggested that, right?), maybe we could disable it after the next release, if the additional stage takes too long. But it's fine now to test that all of that works.

Edit: the condition of the docker stage wasn't changed, so it's still only built for releases.

@alexarchambault
Copy link
Member

So merging, thanks!

@alexarchambault alexarchambault merged commit 5fc241a into almond-sh:master Mar 27, 2019
@sbrunk
Copy link
Member Author

sbrunk commented Mar 27, 2019

The docker stage fails because there's a versioning issue.

Cause by this linein update-docker-images.sh because on travis it uses git versioning.
Locally it bumps the minor version and adds SNAPSHOT which I have done in the script too.

@sbrunk
Copy link
Member Author

sbrunk commented Mar 27, 2019

I guess the most robust fix would be to get the version out of sbt somehow.

@alexarchambault
Copy link
Member

We can always set the version right before the publishLocal, with something like sbt 'set version in ThisBuild := "0.1-docker"' +publishLocal, and use 0.1-docker down the line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants